package cn.cutie.clotcache.command;

import cn.cutie.clotcache.core.ClotCache;
import cn.cutie.clotcache.core.Command;
import cn.cutie.clotcache.core.Reply;

/**
 * @Description:
 * @Author: Cutie
 * @CreateDate: 2024/6/20 14:20
 * @Version: 0.0.1
 */
public class LindexCommand implements Command {
    @Override
    public String name() {
        return "LINDEX";
    }

    @Override
    public Reply<?> exec(ClotCache cache, String[] args) {
        String key = getKey(args);
        int index = Integer.parseInt(getValue(args));
        return Reply.bulkString(cache.lindex(key, index));
    }
}
